package com.xiaotao.realtimeui.po;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.codehaus.jackson.map.ObjectMapper;

import java.io.IOException;
import java.util.Random;
import java.util.UUID;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class PaymentInfo {
    private String orderId;
    private String productId;
    private long productPrice;

    public String random() {
        Random r = new Random();
        orderId = UUID.randomUUID().toString().replaceAll("-", "");
        productPrice = r.nextInt(1000);
        productId = r.nextInt(10) + "";
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.writeValueAsString(this);
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }
}
